Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: range hover #839

Merged
merged 2 commits into from
Aug 12, 2021
Merged

feat: range hover #839

merged 2 commits into from
Aug 12, 2021

Conversation

fannheyward
Copy link
Owner

close #836
FYI #256

src/client.ts Show resolved Hide resolved
@resolritter
Copy link

With the adjustments from #839 (comment) I was able to execute it:

vnoremap <silent> <buffer> K <cmd>call CocActionAsync('doHover')<CR>

@resolritter
Copy link

Unrelated to this PR, but tsserver was complaining about Property 'markdown' is missing in LanguageClientOptions when I opened that src/client.ts file. In coc.nvim master it's optional so maybe the typings here are outdated? In any case feel free to disregard this

@fannheyward
Copy link
Owner Author

Property 'markdown' is missing in LanguageClientOptions

You can ignore this, this has been fixed already but the typings was not published neoclide/coc.nvim#3232.

@fannheyward
Copy link
Owner Author

Thank you @resolritter , range hover is working in my tests, this can't be here without your help, thank you!

Copy link

@resolritter resolritter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this :-)

@fannheyward fannheyward merged commit 6574b52 into master Aug 12, 2021
@fannheyward fannheyward deleted the feat/range-hover branch August 12, 2021 02:14
@TonalidadeHidrica
Copy link

Hello. Could you tell me how I can use this feature? I'm using neovim + coc.nvim + rust-analyzer. I have the following lines in ~/..config/nvim/init.nvim:

" Use K to show documentation in preview window.
nnoremap <silent> K <cmd>call <SID>show_documentation()<CR>
vnoremap <silent> K <cmd>call <SID>show_documentation()<CR>

function! s:show_documentation()
  if (index(['vim','help'], &filetype) >= 0)
    execute 'h '.expand('<cword>')
  else
    call CocActionAsync('doHover')
  endif
endfunction

However, after entering to visual mode and selecting some portion of code, when I type K, nothing shows up. On the other hand, in normal mode, when the cursor is on an identifier, if I type K a floating window of its documentation appears. Did I configure wrong way?

Here is the link for my entire configuration files under ~/.config/nvim/: https://github.com/TonalidadeHidrica/dotfiles/tree/master/.config/nvim .

And here are the versions that I use:

neovim --version
NVIM v0.6.0-dev+nightly-756-g8c74c895b
Build type: Release
LuaJIT 2.1.0-beta3
Compiled by username@*******

Features: +acl +iconv +tui
See ":help feature-compile"

      システム vimrc: "$VIM/sysinit.vim"
       省略時の $VIM: "/usr/local/Cellar/neovim/HEAD-8c74c89/share/nvim"

Run :checkhealth for more info
:CocInfo

Note that I typed K in normal mode at 01:22:25, and in visual mode at 01:22:29.

undefined## versions

vim version: NVIM v0.6.0-dev+nightly-756-g8c74c895b
node version: v14.18.1
coc.nvim version: 0.0.80-03c9add7cd
coc.nvim directory: /Users/username/.vim/dein/.cache/init.vim/.dein
term: tmux
platform: darwin

## Log of coc.nvim

2021-10-19T01:13:17.874 INFO (pid:19230) [services] - registered service "languageserver.haskell"
2021-10-19T01:13:17.921 INFO (pid:19230) [services] - registered service "rust-analyzer"
2021-10-19T01:13:17.921 INFO (pid:19230) [services] - Rust Analyzer Language Server state change: stopped => starting
2021-10-19T01:13:17.935 INFO (pid:19230) [plugin] - coc.nvim 0.0.80-03c9add7cd initialized with node: v14.18.1 after 178ms
2021-10-19T01:13:17.941 INFO (pid:19230) [language-client-index] - Language server "rust-analyzer" started with 19268
2021-10-19T01:13:17.955 INFO (pid:19230) [services] - Rust Analyzer Language Server state change: starting => running
2021-10-19T01:13:17.961 INFO (pid:19230) [services] - service rust-analyzer started
2021-10-19T01:13:18.054 INFO (pid:19230) [watchman] - watchman watching project: /Users/username/path/to/project
2021-10-19T01:13:36.834 INFO (pid:19230) [attach] - receive notification: highlight []
2021-10-19T01:13:37.921 INFO (pid:19230) [attach] - receive notification: doHover []
2021-10-19T01:13:40.341 WARN (pid:19230) [plugin] - Slow action "highlight" cost 3507ms
2021-10-19T01:13:40.451 WARN (pid:19230) [plugin] - Slow action "doHover" cost 2529ms
2021-10-19T01:13:40.760 INFO (pid:19230) [attach] - receive notification: highlight []
2021-10-19T01:13:44.583 INFO (pid:19230) [attach] - receive notification: highlight []
2021-10-19T01:13:44.610 INFO (pid:19230) [attach] - receive notification: doHover []
2021-10-19T01:13:44.938 INFO (pid:19230) [attach] - receive notification: highlight []
2021-10-19T01:13:46.400 INFO (pid:19230) [attach] - receive notification: doHover []
2021-10-19T01:13:46.737 INFO (pid:19230) [attach] - receive notification: highlight []
2021-10-19T01:13:49.397 INFO (pid:19230) [attach] - receive notification: doHover []
2021-10-19T01:13:49.763 INFO (pid:19230) [attach] - receive notification: highlight []
2021-10-19T01:13:50.875 INFO (pid:19230) [attach] - receive notification: doHover []
2021-10-19T01:13:51.245 INFO (pid:19230) [attach] - receive notification: highlight []
2021-10-19T01:13:59.357 INFO (pid:19230) [attach] - receive notification: highlight []
2021-10-19T01:14:00.530 INFO (pid:19230) [attach] - receive notification: doHover []
2021-10-19T01:14:01.745 INFO (pid:19230) [attach] - receive notification: highlight []
2021-10-19T01:14:52.145 INFO (pid:19230) [attach] - receive notification: highlight []
2021-10-19T01:15:08.902 INFO (pid:19230) [attach] - receive notification: highlight []
2021-10-19T01:15:09.952 INFO (pid:19230) [attach] - receive notification: highlight []
2021-10-19T01:15:12.495 INFO (pid:19230) [attach] - receive notification: highlight []
2021-10-19T01:19:41.858 INFO (pid:19230) [attach] - receive notification: showInfo []
2021-10-19T01:19:42.503 INFO (pid:19230) [attach] - receive notification: highlight []
2021-10-19T01:19:45.810 INFO (pid:19230) [attach] - receive notification: highlight []
2021-10-19T01:20:03.268 INFO (pid:19230) [attach] - receive notification: highlight []
2021-10-19T01:20:04.340 INFO (pid:19230) [attach] - receive notification: highlight []
2021-10-19T01:20:05.056 INFO (pid:19230) [attach] - receive notification: highlight []
2021-10-19T01:20:06.456 INFO (pid:19230) [attach] - receive notification: highlight []
2021-10-19T01:20:07.374 INFO (pid:19230) [attach] - receive notification: highlight []
2021-10-19T01:20:11.164 INFO (pid:19230) [attach] - receive notification: highlight []
2021-10-19T01:20:12.596 INFO (pid:19230) [attach] - receive notification: doHover []
2021-10-19T01:20:14.729 INFO (pid:19230) [attach] - receive notification: highlight []
2021-10-19T01:20:18.763 INFO (pid:19230) [attach] - receive notification: highlight []
2021-10-19T01:20:19.555 INFO (pid:19230) [attach] - receive notification: doHover []
2021-10-19T01:20:19.922 INFO (pid:19230) [attach] - receive notification: highlight []
2021-10-19T01:20:20.859 INFO (pid:19230) [attach] - receive notification: highlight []
2021-10-19T01:20:22.473 INFO (pid:19230) [attach] - receive notification: highlight []
2021-10-19T01:20:25.735 INFO (pid:19230) [attach] - receive notification: showInfo []
2021-10-19T01:20:26.049 INFO (pid:19230) [attach] - receive notification: highlight []
2021-10-19T01:20:28.332 INFO (pid:19230) [attach] - receive notification: highlight []
2021-10-19T01:20:42.401 INFO (pid:19230) [attach] - receive notification: highlight []
2021-10-19T01:20:43.423 INFO (pid:19230) [attach] - receive notification: highlight []
2021-10-19T01:20:45.782 INFO (pid:19230) [attach] - receive notification: highlight []
2021-10-19T01:20:47.025 INFO (pid:19230) [attach] - receive notification: doHover []
2021-10-19T01:20:47.347 INFO (pid:19230) [attach] - receive notification: highlight []
2021-10-19T01:20:48.475 INFO (pid:19230) [attach] - receive notification: highlight []
2021-10-19T01:20:52.993 INFO (pid:19230) [attach] - receive notification: doHover []
2021-10-19T01:20:56.709 INFO (pid:19230) [attach] - receive notification: highlight []
2021-10-19T01:20:59.465 INFO (pid:19230) [attach] - receive notification: showInfo []
2021-10-19T01:21:00.088 INFO (pid:19230) [attach] - receive notification: highlight []
2021-10-19T01:21:02.656 INFO (pid:19230) [attach] - receive notification: highlight []
2021-10-19T01:21:03.355 INFO (pid:19230) [attach] - receive notification: highlight []
2021-10-19T01:21:03.853 INFO (pid:19230) [attach] - receive notification: highlight []
2021-10-19T01:21:04.441 INFO (pid:19230) [attach] - receive notification: highlight []
2021-10-19T01:21:05.120 INFO (pid:19230) [attach] - receive notification: highlight []
2021-10-19T01:21:32.915 INFO (pid:19230) [attach] - receive notification: highlight []
2021-10-19T01:21:34.159 INFO (pid:19230) [attach] - receive notification: highlight []
2021-10-19T01:21:34.529 INFO (pid:19230) [attach] - receive notification: highlight []
2021-10-19T01:21:37.318 INFO (pid:19230) [attach] - receive notification: highlight []
2021-10-19T01:21:38.069 INFO (pid:19230) [attach] - receive notification: highlight []
2021-10-19T01:21:40.495 INFO (pid:19230) [attach] - receive notification: highlight []
2021-10-19T01:21:41.656 INFO (pid:19230) [attach] - receive notification: highlight []
2021-10-19T01:22:03.418 INFO (pid:19230) [attach] - receive notification: highlight []
2021-10-19T01:22:04.506 INFO (pid:19230) [attach] - receive notification: highlight []
2021-10-19T01:22:06.863 INFO (pid:19230) [attach] - receive notification: highlight []
2021-10-19T01:22:07.871 INFO (pid:19230) [attach] - receive notification: highlight []
2021-10-19T01:22:08.226 INFO (pid:19230) [attach] - receive notification: highlight []
2021-10-19T01:22:09.836 INFO (pid:19230) [attach] - receive notification: highlight []
2021-10-19T01:22:10.208 INFO (pid:19230) [attach] - receive notification: highlight []
2021-10-19T01:22:11.736 INFO (pid:19230) [attach] - receive notification: highlight []
2021-10-19T01:22:12.095 INFO (pid:19230) [attach] - receive notification: highlight []
2021-10-19T01:22:16.025 INFO (pid:19230) [attach] - receive notification: highlight []
2021-10-19T01:22:16.926 INFO (pid:19230) [attach] - receive notification: highlight []
2021-10-19T01:22:21.941 INFO (pid:19230) [attach] - receive notification: highlight []
2021-10-19T01:22:25.099 INFO (pid:19230) [attach] - receive notification: doHover []
2021-10-19T01:22:25.419 INFO (pid:19230) [attach] - receive notification: highlight []
2021-10-19T01:22:29.912 INFO (pid:19230) [attach] - receive notification: doHover []
2021-10-19T01:22:32.271 INFO (pid:19230) [attach] - receive notification: highlight []
2021-10-19T01:22:41.825 INFO (pid:19230) [attach] - receive notification: showInfo []
:CocCommand rust-analyzer.serverVersion
[coc.nvim] rust-analyzer 91cbda43c 2021-10-18 stable

@resolritter
Copy link

resolritter commented Oct 19, 2021

My exact mapping is as follows: vnoremap <silent> <buffer> gh <cmd>call CocActionAsync('doHover')<CR>. I don't see anything wrong with yours.

It's possible that you don't have a recent enough rust-analyzer version which has the range hover feature.

@TonalidadeHidrica
Copy link

Thanks for your information. I removed the lines I wrote above and replaced with yours, but it does not still show up. Also, I have the latest stable rust-analyzer build, as described at the bottom of my last comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Range hover support
3 participants